/**
 *
 */
import OSS;
import OpenPlatform;
import OSSUtil;
import FileForm;
import OpenApi;
import OpenApi.OpenApiUtil;

extends OpenApi;


init(config: OpenApiUtil.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('umeng-apm', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!$isNull(endpoint)) {
    return endpoint;
  }
  
  if (!$isNull(endpointMap) && !$isNull(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return OpenApiUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model DeleteSymRecordsRequest {
  appVersions?: [ string ](name='appVersions', description='This parameter is required.'),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  fileType?: int32(name='fileType', description='This parameter is required.', example='1'),
}

model DeleteSymRecordsShrinkRequest {
  appVersionsShrink?: string(name='appVersions', description='This parameter is required.'),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  fileType?: int32(name='fileType', description='This parameter is required.', example='1'),
}

model DeleteSymRecordsResponseBody = {
  code?: long(name='code', description='code', example='200'),
  msg?: string(name='msg', example='succeed in handling request'),
  num?: int32(name='num', example='1'),
  success?: boolean(name='success', example='true'),
  traceId?: string(name='traceId', description='traceId', example='210f07c516457690916816858d94ea'),
}

model DeleteSymRecordsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteSymRecordsResponseBody(name='body'),
}

/**
 * @summary 删除符号表记录
 *
 * @param tmpReq DeleteSymRecordsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteSymRecordsResponse
 */
async function deleteSymRecordsWithOptions(tmpReq: DeleteSymRecordsRequest, headers: map[string]string, runtime: $RuntimeOptions): DeleteSymRecordsResponse {
  tmpReq.validate();
  var request = new DeleteSymRecordsShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!$isNull(tmpReq.appVersions)) {
    request.appVersionsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.appVersions, 'appVersions', 'simple');
  }
  var body : map[string]any = {};
  if (!$isNull(request.appVersionsShrink)) {
    body['appVersions'] = request.appVersionsShrink;
  }
  if (!$isNull(request.dataSourceId)) {
    body['dataSourceId'] = request.dataSourceId;
  }
  if (!$isNull(request.fileType)) {
    body['fileType'] = request.fileType;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'DeleteSymRecords',
    version = '2022-02-14',
    protocol = 'HTTPS',
    pathname = `/deleteSymRecords`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 删除符号表记录
 *
 * @param request DeleteSymRecordsRequest
 * @return DeleteSymRecordsResponse
 */
async function deleteSymRecords(request: DeleteSymRecordsRequest): DeleteSymRecordsResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteSymRecordsWithOptions(request, headers, runtime);
}

model GetErrorMinuteStatTrendRequest {
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  startTime?: string(name='startTime', description='This parameter is required.', example='2024-09-27 09:07'),
  type?: int32(name='type', description='This parameter is required.', example='1'),
}

model GetErrorMinuteStatTrendResponseBody = {
  code?: long(name='code', example='200'),
  data?: [ 
    {
      errorCount?: long(name='errorCount', example='120'),
      launchCount?: long(name='launchCount', example='1200'),
      timePoint?: string(name='timePoint', example='2023-05-20 13:01'),
    }
  ](name='data'),
  msg?: string(name='msg', example='succeed in handling request'),
  success?: boolean(name='success', example='true'),
}

model GetErrorMinuteStatTrendResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetErrorMinuteStatTrendResponseBody(name='body'),
}

/**
 * @summary 获取分钟粒度稳定性统计数据
 *
 * @param request GetErrorMinuteStatTrendRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetErrorMinuteStatTrendResponse
 */
async function getErrorMinuteStatTrendWithOptions(request: GetErrorMinuteStatTrendRequest, headers: map[string]string, runtime: $RuntimeOptions): GetErrorMinuteStatTrendResponse {
  request.validate();
  var query : map[string]any = {};
  if (!$isNull(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!$isNull(request.startTime)) {
    query['startTime'] = request.startTime;
  }
  if (!$isNull(request.type)) {
    query['type'] = request.type;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetErrorMinuteStatTrend',
    version = '2022-02-14',
    protocol = 'HTTPS',
    pathname = `/stat/GetErrorMinuteStatTrend`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取分钟粒度稳定性统计数据
 *
 * @param request GetErrorMinuteStatTrendRequest
 * @return GetErrorMinuteStatTrendResponse
 */
async function getErrorMinuteStatTrend(request: GetErrorMinuteStatTrendRequest): GetErrorMinuteStatTrendResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return getErrorMinuteStatTrendWithOptions(request, headers, runtime);
}

model GetH5PageTrendRequest {
  appVersion?: string(name='appVersion', example='1.0.2'),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  endDate?: string(name='endDate', description='This parameter is required.', example='2023-05-03'),
  startDate?: string(name='startDate', description='This parameter is required.', example='2023-05-01'),
  timeUnit?: string(name='timeUnit', description='This parameter is required.', example='day'),
}

model GetH5PageTrendResponseBody = {
  code?: long(name='code', example='200'),
  data?: [ 
    {
      analyzeDOM?: double(name='analyzeDOM', example='504.89'),
      appCache?: double(name='appCache', example='49.48'),
      contentTrans?: double(name='contentTrans', example='979.83'),
      dns?: double(name='dns', example='50.16'),
      domReady?: double(name='domReady', example='1881.96'),
      fcp?: double(name='fcp', example='190.69'),
      firstByte?: double(name='firstByte', example='472.57'),
      fiveSecondRate?: double(name='fiveSecondRate', example='44.67'),
      fp?: double(name='fp', example='50.25'),
      loadEvent?: double(name='loadEvent', example='492.86'),
      loadFinish?: double(name='loadFinish', example='4741.44'),
      loadResource?: double(name='loadResource', example='2549.46'),
      logCnt?: long(name='logCnt', example='2062'),
      oneSecondRate?: double(name='oneSecondRate', example='0.19'),
      redirect?: double(name='redirect', example='100.93'),
      ssl?: double(name='ssl', example='71.02'),
      tcp?: double(name='tcp', example='150.18'),
      timePoint?: string(name='timePoint', example='2023-05-20'),
      ttfb?: double(name='ttfb', example='249.55'),
      tti?: double(name='tti', example='2126.61'),
      twoSecondRate?: double(name='twoSecondRate', example='4.9'),
      unload?: double(name='unload', example='98.26'),
    }
  ](name='data'),
  msg?: string(name='msg', example='succeed in handling request'),
  success?: boolean(name='success', example='true'),
}

model GetH5PageTrendResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetH5PageTrendResponseBody(name='body'),
}

/**
 * @summary 获取H5页面性能统计数据
 *
 * @param request GetH5PageTrendRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetH5PageTrendResponse
 */
async function getH5PageTrendWithOptions(request: GetH5PageTrendRequest, headers: map[string]string, runtime: $RuntimeOptions): GetH5PageTrendResponse {
  request.validate();
  var query : map[string]any = {};
  if (!$isNull(request.appVersion)) {
    query['appVersion'] = request.appVersion;
  }
  if (!$isNull(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!$isNull(request.endDate)) {
    query['endDate'] = request.endDate;
  }
  if (!$isNull(request.startDate)) {
    query['startDate'] = request.startDate;
  }
  if (!$isNull(request.timeUnit)) {
    query['timeUnit'] = request.timeUnit;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetH5PageTrend',
    version = '2022-02-14',
    protocol = 'HTTPS',
    pathname = `/stat/getH5PageTrend`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取H5页面性能统计数据
 *
 * @param request GetH5PageTrendRequest
 * @return GetH5PageTrendResponse
 */
async function getH5PageTrend(request: GetH5PageTrendRequest): GetH5PageTrendResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return getH5PageTrendWithOptions(request, headers, runtime);
}

model GetLaunchTrendRequest {
  appVersion?: string(name='appVersion', example='1.0.2'),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  endDate?: string(name='endDate', description='This parameter is required.', example='2023-05-03'),
  startDate?: string(name='startDate', description='This parameter is required.', example='2023-05-01'),
  timeUnit?: string(name='timeUnit', description='This parameter is required.', example='day'),
}

model GetLaunchTrendResponseBody = {
  code?: long(name='code', example='200'),
  data?: [ 
    {
      coldLaunchCount?: long(name='coldLaunchCount', example='2495'),
      coldLaunchDuration?: double(name='coldLaunchDuration', example='3784.5'),
      firstLaunchCount?: long(name='firstLaunchCount', example='2495'),
      firstLaunchDuration?: double(name='firstLaunchDuration', example='3740.5'),
      hotLaunchCount?: long(name='hotLaunchCount', example='2495'),
      hotLaunchDuration?: double(name='hotLaunchDuration', example='1400.5'),
      timePoint?: string(name='timePoint', example='2023-05-20'),
    }
  ](name='data'),
  msg?: string(name='msg', example='succeed in handling request'),
  success?: boolean(name='success', example='true'),
}

model GetLaunchTrendResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetLaunchTrendResponseBody(name='body'),
}

/**
 * @summary 获取启动性能统计数据
 *
 * @param request GetLaunchTrendRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetLaunchTrendResponse
 */
async function getLaunchTrendWithOptions(request: GetLaunchTrendRequest, headers: map[string]string, runtime: $RuntimeOptions): GetLaunchTrendResponse {
  request.validate();
  var query : map[string]any = {};
  if (!$isNull(request.appVersion)) {
    query['appVersion'] = request.appVersion;
  }
  if (!$isNull(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!$isNull(request.endDate)) {
    query['endDate'] = request.endDate;
  }
  if (!$isNull(request.startDate)) {
    query['startDate'] = request.startDate;
  }
  if (!$isNull(request.timeUnit)) {
    query['timeUnit'] = request.timeUnit;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetLaunchTrend',
    version = '2022-02-14',
    protocol = 'HTTPS',
    pathname = `/stat/getLaunchTrend`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取启动性能统计数据
 *
 * @param request GetLaunchTrendRequest
 * @return GetLaunchTrendResponse
 */
async function getLaunchTrend(request: GetLaunchTrendRequest): GetLaunchTrendResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return getLaunchTrendWithOptions(request, headers, runtime);
}

model GetNativePageTrendRequest {
  appVersion?: string(name='appVersion', example='1.0.2'),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  endDate?: string(name='endDate', description='This parameter is required.', example='2023-05-03'),
  startDate?: string(name='startDate', description='This parameter is required.', example='2023-05-01'),
  timeUnit?: string(name='timeUnit', description='This parameter is required.', example='day'),
}

model GetNativePageTrendResponseBody = {
  code?: long(name='code', example='200'),
  data?: [ 
    {
      avgLoadDuration?: double(name='avgLoadDuration', example='75.9'),
      crashRate?: double(name='crashRate', example='37.317'),
      loadCnt?: long(name='loadCnt', example='2460'),
      slowLoadRate?: double(name='slowLoadRate', example='99.837'),
      timePoint?: string(name='timePoint', example='2023-05-20'),
    }
  ](name='data'),
  msg?: string(name='msg', example='succeed in handling request'),
  success?: boolean(name='success', example='true'),
}

model GetNativePageTrendResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetNativePageTrendResponseBody(name='body'),
}

/**
 * @summary 获取原生页面性能统计数据
 *
 * @param request GetNativePageTrendRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetNativePageTrendResponse
 */
async function getNativePageTrendWithOptions(request: GetNativePageTrendRequest, headers: map[string]string, runtime: $RuntimeOptions): GetNativePageTrendResponse {
  request.validate();
  var query : map[string]any = {};
  if (!$isNull(request.appVersion)) {
    query['appVersion'] = request.appVersion;
  }
  if (!$isNull(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!$isNull(request.endDate)) {
    query['endDate'] = request.endDate;
  }
  if (!$isNull(request.startDate)) {
    query['startDate'] = request.startDate;
  }
  if (!$isNull(request.timeUnit)) {
    query['timeUnit'] = request.timeUnit;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetNativePageTrend',
    version = '2022-02-14',
    protocol = 'HTTPS',
    pathname = `/stat/getNativePageTrend`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取原生页面性能统计数据
 *
 * @param request GetNativePageTrendRequest
 * @return GetNativePageTrendResponse
 */
async function getNativePageTrend(request: GetNativePageTrendRequest): GetNativePageTrendResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return getNativePageTrendWithOptions(request, headers, runtime);
}

model GetNetworkMinuteTrendRequest {
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  startTime?: string(name='startTime', description='This parameter is required.', example='2024-09-27 09:07'),
}

model GetNetworkMinuteTrendResponseBody = {
  code?: long(name='code', example='200'),
  data?: [ 
    {
      errorCount?: long(name='errorCount', example='120'),
      requestCount?: long(name='requestCount', example='1200'),
      timePoint?: string(name='timePoint', example='2023-05-20 09:08'),
    }
  ](name='data'),
  msg?: string(name='msg', example='succeed in handling request'),
  success?: boolean(name='success', example='true'),
}

model GetNetworkMinuteTrendResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetNetworkMinuteTrendResponseBody(name='body'),
}

/**
 * @summary 获取分钟粒度网络统计数据
 *
 * @param request GetNetworkMinuteTrendRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetNetworkMinuteTrendResponse
 */
async function getNetworkMinuteTrendWithOptions(request: GetNetworkMinuteTrendRequest, headers: map[string]string, runtime: $RuntimeOptions): GetNetworkMinuteTrendResponse {
  request.validate();
  var query : map[string]any = {};
  if (!$isNull(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!$isNull(request.startTime)) {
    query['startTime'] = request.startTime;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetNetworkMinuteTrend',
    version = '2022-02-14',
    protocol = 'HTTPS',
    pathname = `/stat/getNetworkMinuteTrend`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取分钟粒度网络统计数据
 *
 * @param request GetNetworkMinuteTrendRequest
 * @return GetNetworkMinuteTrendResponse
 */
async function getNetworkMinuteTrend(request: GetNetworkMinuteTrendRequest): GetNetworkMinuteTrendResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return getNetworkMinuteTrendWithOptions(request, headers, runtime);
}

model GetNetworkTrendRequest {
  appVersion?: string(name='appVersion', example='1.0.2'),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  endDate?: string(name='endDate', description='This parameter is required.', example='2023-05-03'),
  startDate?: string(name='startDate', description='This parameter is required.', example='2023-05-01'),
  timeUnit?: string(name='timeUnit', description='This parameter is required.', example='day'),
}

model GetNetworkTrendResponseBody = {
  code?: long(name='code', example='200'),
  data?: [ 
    {
      avgCost?: double(name='avgCost', example='4402.8'),
      avgResponseTime?: double(name='avgResponseTime', example='1654.51'),
      avgTransformBytes?: double(name='avgTransformBytes', example='3299.43'),
      requestPerMinute?: double(name='requestPerMinute', example='1.61'),
      timePoint?: string(name='timePoint', example='2023-05-20'),
    }
  ](name='data'),
  msg?: string(name='msg', example='succeed in handling request'),
  success?: boolean(name='success', example='true'),
}

model GetNetworkTrendResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetNetworkTrendResponseBody(name='body'),
}

/**
 * @summary 获取网络性能统计数据
 *
 * @param request GetNetworkTrendRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetNetworkTrendResponse
 */
async function getNetworkTrendWithOptions(request: GetNetworkTrendRequest, headers: map[string]string, runtime: $RuntimeOptions): GetNetworkTrendResponse {
  request.validate();
  var query : map[string]any = {};
  if (!$isNull(request.appVersion)) {
    query['appVersion'] = request.appVersion;
  }
  if (!$isNull(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!$isNull(request.endDate)) {
    query['endDate'] = request.endDate;
  }
  if (!$isNull(request.startDate)) {
    query['startDate'] = request.startDate;
  }
  if (!$isNull(request.timeUnit)) {
    query['timeUnit'] = request.timeUnit;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetNetworkTrend',
    version = '2022-02-14',
    protocol = 'HTTPS',
    pathname = `/stat/getNetworkTrend`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取网络性能统计数据
 *
 * @param request GetNetworkTrendRequest
 * @return GetNetworkTrendResponse
 */
async function getNetworkTrend(request: GetNetworkTrendRequest): GetNetworkTrendResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return getNetworkTrendWithOptions(request, headers, runtime);
}

model GetStatTrendRequest {
  appVersion?: string(name='appVersion', example='1.0'),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  endDate?: string(name='endDate', example='2021-06-03'),
  startDate?: string(name='startDate', example='2021-06-01'),
  type?: int32(name='type', description='This parameter is required.', example='1'),
}

model GetStatTrendResponseBody = {
  code?: long(name='code', example='200'),
  data?: [ 
    {
      affectedUserCount?: long(name='affectedUserCount', example='52'),
      affectedUserRate?: double(name='affectedUserRate', example='10.3'),
      errorCount?: long(name='errorCount', example='120'),
      errorRate?: double(name='errorRate', example='25.6'),
      timePoint?: string(name='timePoint', example='2021-06-01'),
    }
  ](name='data'),
  msg?: string(name='msg', example='succeed in handling request'),
  success?: boolean(name='success', example='true'),
}

model GetStatTrendResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetStatTrendResponseBody(name='body'),
}

/**
 * @summary 获取离线统计数据
 *
 * @param request GetStatTrendRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetStatTrendResponse
 */
async function getStatTrendWithOptions(request: GetStatTrendRequest, headers: map[string]string, runtime: $RuntimeOptions): GetStatTrendResponse {
  request.validate();
  var query : map[string]any = {};
  if (!$isNull(request.appVersion)) {
    query['appVersion'] = request.appVersion;
  }
  if (!$isNull(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!$isNull(request.endDate)) {
    query['endDate'] = request.endDate;
  }
  if (!$isNull(request.startDate)) {
    query['startDate'] = request.startDate;
  }
  if (!$isNull(request.type)) {
    query['type'] = request.type;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetStatTrend',
    version = '2022-02-14',
    protocol = 'HTTPS',
    pathname = `/stat/getStatTrend`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取离线统计数据
 *
 * @param request GetStatTrendRequest
 * @return GetStatTrendResponse
 */
async function getStatTrend(request: GetStatTrendRequest): GetStatTrendResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return getStatTrendWithOptions(request, headers, runtime);
}

model GetSymUploadParamRequest {
  appVersion?: string(name='appVersion', description='This parameter is required.', example='1.0.3'),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  fileName?: string(name='fileName', description='This parameter is required.', example='symbol.zip'),
  fileType?: int32(name='fileType', description='This parameter is required.', example='1'),
  flutterName?: string(name='flutterName', example='my-flutter-app'),
}

model GetSymUploadParamResponseBody = {
  code?: long(name='code', example='200'),
  data?: {
    accessKeyId?: string(name='accessKeyId', example='LTAI5tM4ZXXXXX'),
    callback?: string(name='callback', example='eyJjYWxsYmFja1VybCI6Imh0dHBzOi8vYXBtLnVtZW5nLmNvbS9oc2Yvc3ltL29zcy9ub3RpZnlNc2ciLCJjYqc29uIn0='),
    key?: string(name='key', example='tmp/20220428/5fb6001a73749c24fd9cb356_f49a08dc1225438188c109fcf92eb9f3/symbol.zip'),
    policy?: string(name='policy', example='eyJleHBpcmF0aW9uIjoiMjAyMi0wNC0yOFQwNDoxMzo0MS43OTJaIiwiY29uZGl0aW9ucyI6W1siZXEiLCIka2V5IiwidG1WpveGZTSXNJbU5oYkd4aVlXTnJRbTlrZVZSNWNHVWlPaUpoY0hCc2FXTmhkR2x2Ymk5cWMyOXVJbjA9In1dfQ=='),
    signature?: string(name='signature', example='3f67c435e08d164f41f6e522a2b5d1d7feb93000'),
    uploadAddress?: string(name='uploadAddress', example='https://quickbird.oss-cn-shanghai.aliyuncs.com'),
  }(name='data', description='data'),
  msg?: string(name='msg', example='succeed in handling request'),
  success?: boolean(name='success', example='true'),
  traceId?: string(name='traceId', description='traceId', example='210f07c516457690916816858d94ea'),
}

model GetSymUploadParamResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetSymUploadParamResponseBody(name='body'),
}

/**
 * @summary 获取符号表文件上传参数
 *
 * @param request GetSymUploadParamRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetSymUploadParamResponse
 */
async function getSymUploadParamWithOptions(request: GetSymUploadParamRequest, headers: map[string]string, runtime: $RuntimeOptions): GetSymUploadParamResponse {
  request.validate();
  var query : map[string]any = {};
  if (!$isNull(request.appVersion)) {
    query['appVersion'] = request.appVersion;
  }
  if (!$isNull(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!$isNull(request.fileName)) {
    query['fileName'] = request.fileName;
  }
  if (!$isNull(request.fileType)) {
    query['fileType'] = request.fileType;
  }
  if (!$isNull(request.flutterName)) {
    query['flutterName'] = request.flutterName;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetSymUploadParam',
    version = '2022-02-14',
    protocol = 'HTTPS',
    pathname = `/getSymUploadParam`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取符号表文件上传参数
 *
 * @param request GetSymUploadParamRequest
 * @return GetSymUploadParamResponse
 */
async function getSymUploadParam(request: GetSymUploadParamRequest): GetSymUploadParamResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return getSymUploadParamWithOptions(request, headers, runtime);
}

model GetTodayStatTrendRequest {
  appVersion?: string(name='appVersion', example='1.0'),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  type?: int32(name='type', description='This parameter is required.', example='1'),
}

model GetTodayStatTrendResponseBody = {
  code?: long(name='code', example='200'),
  data?: [ 
    {
      affectedUserCount?: long(name='affectedUserCount', example='56'),
      affectedUserRate?: double(name='affectedUserRate', example='10.21'),
      errorCount?: long(name='errorCount', example='120'),
      errorRate?: double(name='errorRate', example='17.24'),
      timePoint?: string(name='timePoint', example='13:00'),
    }
  ](name='data'),
  msg?: string(name='msg', example='succeed in handling request'),
  success?: boolean(name='success', example='true'),
}

model GetTodayStatTrendResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetTodayStatTrendResponseBody(name='body'),
}

/**
 * @summary 获取今日实时统计数据
 *
 * @param request GetTodayStatTrendRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetTodayStatTrendResponse
 */
async function getTodayStatTrendWithOptions(request: GetTodayStatTrendRequest, headers: map[string]string, runtime: $RuntimeOptions): GetTodayStatTrendResponse {
  request.validate();
  var query : map[string]any = {};
  if (!$isNull(request.appVersion)) {
    query['appVersion'] = request.appVersion;
  }
  if (!$isNull(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!$isNull(request.type)) {
    query['type'] = request.type;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetTodayStatTrend',
    version = '2022-02-14',
    protocol = 'HTTPS',
    pathname = `/stat/getTodayStatTrend`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 获取今日实时统计数据
 *
 * @param request GetTodayStatTrendRequest
 * @return GetTodayStatTrendResponse
 */
async function getTodayStatTrend(request: GetTodayStatTrendRequest): GetTodayStatTrendResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return getTodayStatTrendWithOptions(request, headers, runtime);
}

model UpdateAlertPlanRequest {
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  planId?: long(name='planId', description='This parameter is required.', example='18288'),
  versions?: string(name='versions', description='This parameter is required.', example='"1.1.0,1.2.0,1.3.0"'),
}

model UpdateAlertPlanResponseBody = {
  code?: long(name='code', example='200'),
  msg?: string(name='msg', example='Success'),
  success?: boolean(name='success', example='true'),
}

model UpdateAlertPlanResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateAlertPlanResponseBody(name='body'),
}

/**
 * @summary 更新监控告警计划
 *
 * @param request UpdateAlertPlanRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateAlertPlanResponse
 */
async function updateAlertPlanWithOptions(request: UpdateAlertPlanRequest, headers: map[string]string, runtime: $RuntimeOptions): UpdateAlertPlanResponse {
  request.validate();
  var query : map[string]any = {};
  if (!$isNull(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!$isNull(request.planId)) {
    query['planId'] = request.planId;
  }
  if (!$isNull(request.versions)) {
    query['versions'] = request.versions;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'UpdateAlertPlan',
    version = '2022-02-14',
    protocol = 'HTTPS',
    pathname = `/updateAlertPlan`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 更新监控告警计划
 *
 * @param request UpdateAlertPlanRequest
 * @return UpdateAlertPlanResponse
 */
async function updateAlertPlan(request: UpdateAlertPlanRequest): UpdateAlertPlanResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return updateAlertPlanWithOptions(request, headers, runtime);
}

model UploadSymbolFileRequest {
  appVersion?: string(name='appVersion', description='This parameter is required.', example='1.0.3'),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  fileName?: string(name='fileName', description='This parameter is required.', example='symbol.zip'),
  fileType?: int32(name='fileType', description='This parameter is required.', example='1'),
  flutterName?: string(name='flutterName', example='my-flutter-app'),
  ossUrl?: string(name='ossUrl', example='-'),
}

model UploadSymbolFileAdvanceRequest {
  appVersion?: string(name='appVersion', description='This parameter is required.', example='1.0.3'),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='5fb6001a73749c24fd9cb356'),
  fileName?: string(name='fileName', description='This parameter is required.', example='symbol.zip'),
  fileType?: int32(name='fileType', description='This parameter is required.', example='1'),
  flutterName?: string(name='flutterName', example='my-flutter-app'),
  ossUrlObject?: readable(name='ossUrl', example='-'),
}

model UploadSymbolFileResponseBody = {
  code?: long(name='code', description='code', example='200'),
  msg?: string(name='msg', example='succeed in handling request'),
  requestId?: string(name='requestId', example='8B99488B-2B73-502E-A5F2-00B4746F4325'),
  success?: boolean(name='success', example='true'),
  traceId?: string(name='traceId', description='traceId', example='210f07c516457690916816858d94ea'),
}

model UploadSymbolFileResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UploadSymbolFileResponseBody(name='body'),
}

/**
 * @summary 上传符号表文件
 *
 * @param request UploadSymbolFileRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return UploadSymbolFileResponse
 */
async function uploadSymbolFileWithOptions(request: UploadSymbolFileRequest, headers: map[string]string, runtime: $RuntimeOptions): UploadSymbolFileResponse {
  request.validate();
  var query : map[string]any = {};
  if (!$isNull(request.appVersion)) {
    query['appVersion'] = request.appVersion;
  }
  if (!$isNull(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!$isNull(request.fileName)) {
    query['fileName'] = request.fileName;
  }
  if (!$isNull(request.fileType)) {
    query['fileType'] = request.fileType;
  }
  if (!$isNull(request.flutterName)) {
    query['flutterName'] = request.flutterName;
  }
  if (!$isNull(request.ossUrl)) {
    query['ossUrl'] = request.ossUrl;
  }

  var req = new OpenApiUtil.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'UploadSymbolFile',
    version = '2022-02-14',
    protocol = 'HTTPS',
    pathname = `/uploadSymbolFile`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 上传符号表文件
 *
 * @param request UploadSymbolFileRequest
 * @return UploadSymbolFileResponse
 */
async function uploadSymbolFile(request: UploadSymbolFileRequest): UploadSymbolFileResponse {
  var runtime = new $RuntimeOptions{};
  var headers : map[string]string = {};
  return uploadSymbolFileWithOptions(request, headers, runtime);
}

async function uploadSymbolFileAdvance(request: UploadSymbolFileAdvanceRequest, headers: map[string]string, runtime: $RuntimeOptions): UploadSymbolFileResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if($isNull(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if($isNull(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApiUtil.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'umeng-apm',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var uploadSymbolFileReq = new UploadSymbolFileRequest{};
  OpenApiUtil.convert(request, uploadSymbolFileReq);

  if(!$isNull(request.ossUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.ossUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    uploadSymbolFileReq.ossUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var uploadSymbolFileResp = uploadSymbolFileWithOptions(uploadSymbolFileReq, headers, runtime);
  return uploadSymbolFileResp;
}

